package com.ruanko.action;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.ruanko.dao.UploadFileDao;
import com.ruanko.dao.impl.UploadFileDaoImpl;
import com.ruanko.service.FileService;
import com.ruanko.service.impl.FileServiceImpl;


public class UploadAction extends ActionSupport {

 private List<File> file;
 private List<String> fileFileName;
 private List<String> fileContentType;
 private FileService fileService;


 public UploadAction() {
	 this.fileService = new FileServiceImpl();
}

public List<File> getFile() {
  return file;
 }

 public void setFile(List<File> file) {
  this.file = file;
 }

 public List<String> getFileFileName() {
  return fileFileName;
 }

 public void setFileFileName(List<String> fileFileName) {
  this.fileFileName = fileFileName;
 }

 public List<String> getFileContentType() {
  return fileContentType;
 }

 public void setFileContentType(List<String> fileContentType) {
  this.fileContentType = fileContentType;
 }

 @Override
 public String execute() throws Exception {
	 
  
  ArrayList list = fileService.upload(file, this.getFileFileName(), "/files/");
  if (list.size() > 0) {
   return INPUT;
  } else {
   return SUCCESS;
  }
 }

}